package moriarty.gwt.shared;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import javax.persistence.Embedded;

public class User extends DataStoreObject implements Serializable{

	
	
	//For GWT RPC 
	private static final long serialVersionUID = -7970921212296468677L;

	String nickName;
	String firstName;
	String lastName;
    public String email;
	public String gmailEmail;	//In case the user wants to use a separate email to receive SoTDs
	
	public @Embedded LinkedList<Submission> submissions = new LinkedList<Submission>();
	public List<String> groups = new ArrayList<String>();
	
	public User(){}

	public User(String nickName, String firstName, String lastName, String email, String gmailEmail) {
		this.nickName = nickName;
		this.firstName = firstName;
		this.lastName = lastName;
		this.email = email;
		this.gmailEmail = gmailEmail;
		
		escapeUser();
	}
	
	private void escapeUser(){
		
		//Cross Site Scripting Defense
		this.nickName  = Utils.escapeHtml(nickName);
		this.firstName = Utils.escapeHtml(firstName);
		this.lastName  = Utils.escapeHtml(lastName);
		this.email     = Utils.escapeHtml(email);
	}

}
